<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.news.bean.Add_admin;"%>
<%@page import="com.news.dao.*" %>
<%@page import="com.news.dao.impl.*" %>
<%@page import="com.news.util.*" %>
<%
            String path = request.getContextPath();
            String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <base href="<%=basePath%>">

        <title>My JSP 'MyJsp1.jsp' starting page</title>

        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            function page(sender){
                try{
                    var url='PagerServlet?callback=?';
                    var curr=$("#curr").attr("value");
                    <%--var frame='<form name="dataForm" id="dataForm" method="post" action="admin?admin=edituser"><tr bgcolor="#FFFFFF"><td height="25" align="center"><input name="id" type="hidden" id="col_1" value="col_1">col_2</td><td align="center"><input name="password" type="password" class="input" value="col_3" id="userpassword" size="15" dataType="Require"  msg="请填写您的新密码！"><font color="#FF0000">*</font></td><td align="center"><input name="Submit" type="button"  onclick="window.location=\'adminEdit.jsp?addAccount=col_2&password=col_3&id=col_1\'" value=" 修 改 "></td><td align="center"><a href="admin?admin=deluser&id=col_1" onClick="return confirm(\'确定要删除吗?\')">删除</a></td><td align="center">&nbsp;</td></tr></form>';--%>
                    var frame='<tr bgcolor="#FFFFFF"><td height="25" align="center"><input name="id" type="hidden" id="col_1" value="col_1">col_2</td><td align="center"><input name="password" type="password" class="input" value="col_3" id="userpassword" size="15" dataType="Require"  msg="请填写您的新密码！"><font color="#FF0000">*</font></td><td align="center"><input name="Submit" type="button"  onclick="window.location=\'adminEdit.jsp?addAccount=col_2&password=col_3&id=col_1\'" value=" 修 改 "></td><td align="center"><a href="admin?admin=deluser&id=col_1" onClick="return confirm(\'确定要删除吗?\')">删除</a></td><td align="center">&nbsp;</td></tr>';
                    jQuery.getJSON(url,{
                        type : sender.value,
                        current : curr,
                        SQL : 'select * from add_admin',
                        perSize : 10,
                        frames : frame
                    }, function(data){
                        try{
                            var result=decodeURIComponent(data.sucess);
                            result=result.replace(/\+/g,' ');
                            result='<form name="dataForm" id="dataForm" method="post" action="admin?admin=edituser">'+result+'</form>';
                            alert(result);
                            $('#dataForm').replaceWith(result);
                            document.getElementById('dataForm').innerHTML=result;
                        }catch(err){
                            alert(err.message);
                        }
                    });
                }catch(err){
                    alert(err.message);
                }
               
            }
        </script>
    </head>

    <body>
    <LINK href="images/admin_css.css" type=text/css rel=stylesheet>
          <table width="98%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#F2F9FD">
        <tr bgcolor="#D2E8F6">
            <td height="25" colspan="5">&nbsp;&nbsp;管理管理员 <font color="#FF0000">(特别提醒：不要把所有的用户全部删除，否则不能进入后台管理系统！)</font></td>
        </tr>
        <tr align="center" bgcolor="#FFFFFF">
            <td width="100" height="25">用户名</td>
            <td width="150">密码</td>
            <td width="100">修改</td>
            <td width="100">删除</td>
            <td width="250">&nbsp;</td>
        </tr>
        <form name="dataForm" id="dataForm" method="post" action="admin?admin=edituser">
            <%
            int PageNo = 1;
            List<Add_admin> list = (List) request.getAttribute("list");
            if (list != null && list.size() > 0) {
                int i = 1;
                for (Add_admin add : list) {
                    int bil = i + (PageNo - 1) * 3;
            %>

            <tr bgcolor="#FFFFFF" id="result">
                <td height="25" align="center"><input name="id" type="hidden" id="<%=add.getId()%>" value="<%=add.getId()%>">
                <%=add.getAccount_no()%></td>
                <td align="center"><input name="password" type="password" class="input" value="<%=add.getPassword()%>" id="userpassword" size="15" dataType="Require"  msg="请填写您的新密码！">
                    <font color="#FF0000">*</font></td>
                <td align="center"><input name="Submit" type="button"  onclick="window.location='adminEdit.jsp?addAccount=<%=add.getAccount_no()%>&password=<%=add.getPassword()%>&id=<%=add.getId()%>'" value=" 修 改 "></td>
                <td align="center"><a href="admin?admin=deluser&id=<%=add.getId()%>" onClick="return confirm('确定要删除吗?')">删除</a></td>
                <td align="center">&nbsp;</td>
            </tr>
            <%
                    i++;%>
            <%=i%>
            <%
                }

            }%>
        </form>

        <tr align="center" bgcolor="#FFFFFF">
            <td height="35" colspan="5">
                <table border=0 align=center>
                    <TR>
                        <TD align=right>
                            <p align=center>
                                <input type="hidden" name="curr" id="curr" value="0" />
                                <input type="button"id="frist" name="frist" onclick="page(this)" value="首页" title="true">
                                上一页
                                <a>下一页</a>
                                尾页
                                <%
            Add_adminDao addDao = new Add_adminDaoImpl();
            int total = addDao.totaluser();
            Pager pager = new Pager(3, "");
            int pageSize = pager.getPageSize();

            int MaxPage = total % pageSize;
            if (total % pageSize == 0) {
                MaxPage = total / pageSize;
            } else {
                MaxPage = total / pageSize + 1;
            }

                                %>
                                共有<%=total%>条---------<%=pageSize%>----最大页数<%=MaxPage%>
                                转到<INPUT TYEP=TEXT NAME=page SIZE=1 Maxlength=2 VALUE=1>页
                            <INPUT type=submit style="font-size: 9pt" value=GO class=b2></TD>
                    </TR>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>
